package com.my.financial.domain;

import java.io.Serializable;
import java.math.BigDecimal;
import java.util.Date;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.Table;

@Entity
@Table(name="financial_item")
public class FinancialItem implements Serializable {

	/**
	 * 
	 */
	private static final long serialVersionUID = 3514922810610814365L;

	@Id
	@GeneratedValue
	private Long id;
	
	@ManyToOne
	@JoinColumn(name="user_id",columnDefinition="bigint")
	private User user;
	
	@Column(name="member",columnDefinition="varchar(16)")
	private String member;
	
	@Column(name="create_time",columnDefinition="datetime")
	private Date createTime;
	
	@Column(name="type",columnDefinition="varchar(16)")
	private String type;
	
	@Column(name="item",columnDefinition="varchar(32)")
	private String item;
	
	@Column(name="amount",columnDefinition="decimal(11,2)")
	private BigDecimal amount;
	
	@Column(name="summary",columnDefinition="varchar(64)")
	private String summary;
	
	@ManyToOne(cascade= {CascadeType.PERSIST})
	@JoinColumn(name="account_id",columnDefinition="bigint")
	private FinancialAccount account;
	
	public FinancialItem(){
		this.createTime = new Date();
	}
	
	public FinancialItem(User user,FinancialAccount account){
		this.user = user;
		this.createTime = new Date();
		this.account = account;
	}
	
	public FinancialItem(Long id) {
		this.id = id;
	}

	public Long getId() {
		return id;
	}

	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}

	public String getItem() {
		return item;
	}

	public void setItem(String item) {
		this.item = item;
	}

	public String getSummary() {
		return summary;
	}

	public void setSummary(String summary) {
		this.summary = summary;
	}

	public BigDecimal getAmount() {
		return amount;
	}

	public void setAmount(BigDecimal amount) {
		this.amount = amount;
	}

	public Date getCreateTime() {
		return createTime;
	}

	public FinancialAccount getAccount() {
		return account;
	}

	public void setAccount(FinancialAccount account) {
		this.account = account;
	}

	public User getUser() {
		return user;
	}

	public void setUser(User user) {
		this.user = user;
	}

	public String getMember() {
		return member;
	}

	public void setMember(String member) {
		this.member = member;
	}

}
